Imports System.Drawing.Drawing2D

Public Class Form1

    Private Sub ColorPicker1_ColorPicked(ByVal sender As System.Object) Handles ColorPicker1.ColorPicked
        If rbutTextColor.Checked Then
            lblTextSample.ForeColor = ColorPicker1.Value
        Else
            lblTextSample.BackColor = ColorPicker1.Value
        End If
    End Sub

    Private Sub chkHideRGB_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHideRGB.CheckedChanged
        ColorPicker2.HideRGB = chkHideRGB.Checked
    End Sub

    Private bColor As Color = Color.Red
    Private iColor As Color = Color.LightYellow
    Private oColor As Color() = New Color() {Color.Navy}

    Private Sub ColorPicker2_ColorPicked(ByVal sender As System.Object) Handles ColorPicker2.ColorPicked

        If rbutInner.Checked Then
            iColor = ColorPicker2.Value
        ElseIf rbutOuter.Checked() Then
            oColor = New Color() {ColorPicker2.Value}
        Else
            bColor = ColorPicker2.Value
        End If

        PaintBall()

    End Sub

    Sub PaintBall()
        panSample.Refresh()
        Dim g As Graphics = panSample.CreateGraphics
        g.SmoothingMode = SmoothingMode.AntiAlias
        Dim gp As New GraphicsPath
        Dim rect As Rectangle = New Rectangle(3, 3, panSample.Width - 6, panSample.Height - 6)
        gp.AddEllipse(rect)

        Using pbr As PathGradientBrush = New PathGradientBrush(gp)
            pbr.CenterPoint = New PointF((rect.Width / 2) + 3, (rect.Height / 2) + 3)
            pbr.CenterColor = iColor
            pbr.SurroundColors = oColor
            g.FillEllipse(pbr, rect)
        End Using

        Using pn As Pen = New Pen(bColor, 3)
            g.DrawPath(pn, gp)
        End Using

        gp.Dispose()
        g.Dispose()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ColorPicker3.Value = Color.Yellow
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        PaintBall()
    End Sub

    Private Sub rbutTextColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbutTextColor.Click
        ColorPicker1.Value = lblTextSample.ForeColor
    End Sub

    Private Sub rbutBackColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbutBackColor.Click
        ColorPicker1.Value = lblTextSample.BackColor
    End Sub

    Private Sub rbutOuter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbutOuter.Click
        ColorPicker2.Value = oColor(0)
    End Sub

    Private Sub rbutInner_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbutInner.Click
        ColorPicker2.Value = iColor
    End Sub

    Private Sub rbutBorder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbutBorder.Click
        ColorPicker2.Value = bColor
    End Sub

    Private Sub ColorPicker3_ColorChanging(ByVal sender As Object) Handles ColorPicker3.ColorChanging
        Label2.BackColor = ColorPicker3.Value
        Label2.Text = String.Format("   A={0}{1}   R={2}{3}   G={4}{5}   B={6}", _
        ColorPicker3.Value.A, vbCr, ColorPicker3.Value.R, vbCr, ColorPicker3.Value.G, vbCr, ColorPicker3.Value.B)
    End Sub

    Private Sub rbutInner_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbutInner.CheckedChanged

    End Sub
End Class
